<template>
  <!-- <PermissionContainer
    :jiBieArr="[2]"
    :type="4"
    :tipArr="[, '标签配置只对站点级别开放', '', , '您没有开启标签功能']"
  > -->
  <PermissionContainer>
    <div class="label_batch">
      <div class="card card-body">
        <div class="container">
          <div class="row">
            <div class="col-sm col-md-3 offset-md-1">
              <div class="input-group input-group-sm flex-nowrap">
                <div class="input-group-prepend" style="width: 80px"></div>
                <div class="input-group-prepend">
                  <span class="input-group-text" id="addon-wrapping"
                    >油品：</span
                  >
                </div>
                <select
                  class="custom-select"
                  id="inputGroupSelect01"
                  style="width: 80px"
                  v-model="queryParams.oilId"
                >
                  <option :value="undefined" selected>全部</option>
                  <option
                    :value="ele.oilId"
                    v-for="ele in oilList"
                    :key="ele.oilId"
                  >
                    {{ ele.oilName + "-" + ele.oilClass + "-" + ele.oilType }}
                  </option>
                </select>
              </div>
            </div>
            <div class="col-sm col-md-7"></div>
          </div>
          <div class="row">
            <div class="col-sm col-md-3 offset-md-1">
              <div class="input-group input-group-sm flex-nowrap">
                <div class="input-group-prepend" style="width: 80px"></div>
                <div class="input-group-prepend">
                  <span class="input-group-text" id="addon-wrapping"
                    >标签：</span
                  >
                </div>
                <select
                  class="custom-select"
                  id="inputGroupSelect01"
                  style="width: 80px"
                  v-model="queryParams.labelId"
                >
                  <option :value="undefined" selected>全部</option>
                  <option
                    :value="ele.id"
                    v-for="ele in labelList"
                    :key="ele.id"
                  >
                    {{ ele.labelName }}
                  </option>
                </select>
              </div>
            </div>
            <div class="col-sm col-md-8">
              <div class="input-group input-group-sm flex-nowrap">
                <div class="input-group-prepend" style="width: 80px"></div>
                <div class="input-group-prepend">
                  <span class="input-group-text" id="addon-wrapping"
                    >日期：</span
                  >
                  <el-date-picker
                    v-model="searchParams.data"
                    type="datetimerange"
                    value-format="yyyy-MM-dd HH:mm:ss"
                    size="mini"
                    range-separator="至"
                    start-placeholder="开始日期"
                    end-placeholder="结束日期"
                    style="margin-top: 2px; max-width: 350px"
                  >
                  </el-date-picker>
                </div>
              </div>
            </div>
          </div>
          <div class="row">
            <div class="col-sm col-md-9 offset-md-1">
              <div class="input-group input-group-sm flex-nowrap">
                <div class="input-group-prepend" style="width: 80px"></div>
                <div class="input-group-prepend">
                  <span class="input-group-text" id="addon-wrapping"
                    >加油频率：</span
                  >
                </div>
                <input
                  type="text"
                  class="form-control"
                  aria-label="Username"
                  aria-describedby="addon-wrapping"
                  v-model.number="queryParams.startCountNum"
                />
                <div class="input-group-prepend">
                  <span class="input-group-text" id="addon-wrapping">次</span>
                </div>
                <div class="input-group-prepend">
                  <span class="input-group-text" id="addon-wrapping">
                    &lt; 加油次数 &lt;
                  </span>
                </div>
                <input
                  type="text"
                  class="form-control"
                  aria-label="Username"
                  aria-describedby="addon-wrapping"
                  v-model.number="queryParams.endCountNum"
                />
                <div class="input-group-prepend">
                  <span class="input-group-text" id="addon-wrapping">次</span>
                </div>
              </div>
            </div>
          </div>

          <div class="row">
            <div class="col-sm col-md-9 offset-md-1">
              <div class="input-group input-group-sm flex-nowrap">
                <div class="input-group-prepend" style="width: 80px">
                  <select
                    class="custom-select custom-select-sm"
                    id="inputGroupSelect01"
                    v-model="queryParams.amtFlag"
                  >
                    <option value="1">或者</option>
                    <option value="2">并且</option>
                  </select>
                </div>
                <div class="input-group-prepend">
                  <span class="input-group-text" id="addon-wrapping"
                    >加油金额：</span
                  >
                </div>
                <input
                  type="text"
                  class="form-control"
                  aria-label="Username"
                  aria-describedby="addon-wrapping"
                  v-model.number="queryParams.startAmt"
                />
                <div class="input-group-prepend">
                  <span class="input-group-text" id="addon-wrapping">元</span>
                </div>
                <div class="input-group-prepend">
                  <span class="input-group-text" id="addon-wrapping">
                    &lt; 加油金额 &lt;
                  </span>
                </div>
                <input
                  type="text"
                  class="form-control"
                  aria-label="Username"
                  aria-describedby="addon-wrapping"
                  v-model.number="queryParams.endAmt"
                />
                <div class="input-group-prepend">
                  <span class="input-group-text" id="addon-wrapping">元</span>
                </div>
              </div>
            </div>
          </div>
          <div class="row">
            <div class="col-sm col-md-9 offset-md-1">
              <div class="input-group input-group-sm flex-nowrap">
                <div class="input-group-prepend" style="width: 80px">
                  <select
                    class="custom-select custom-select-sm"
                    id="inputGroupSelect01"
                    v-model="queryParams.litersFlag"
                  >
                    <option value="1">或者</option>
                    <option value="2">并且</option>
                  </select>
                </div>
                <div class="input-group-prepend">
                  <span class="input-group-text" id="addon-wrapping"
                    >数量(L/kg)</span
                  >
                </div>
                <input
                  type="text"
                  class="form-control"
                  aria-label="Username"
                  aria-describedby="addon-wrapping"
                  v-model.number="queryParams.startLiters"
                />
                <div class="input-group-prepend">
                  <span class="input-group-text" id="addon-wrapping"
                    >(L/kg)</span
                  >
                </div>
                <div class="input-group-prepend">
                  <span class="input-group-text" id="addon-wrapping">
                    &lt; 数量(L/kg) &lt;
                  </span>
                </div>
                <input
                  type="text"
                  class="form-control"
                  aria-label="Username"
                  aria-describedby="addon-wrapping"
                  v-model.number="queryParams.endLiters"
                />
                <div class="input-group-prepend">
                  <span class="input-group-text" id="addon-wrapping"
                    >(L/kg)</span
                  >
                </div>
              </div>
            </div>
          </div>
          <div class="row mb-0 mt-3" v-show="queryParams.secondFlag == 0">
            <div class="col-sm-4 offset-sm-3">
              <el-button
                type="info"
                size="mini"
                icon="el-icon-arrow-down"
                data-toggle="collapse"
                data-target="#collapseExample"
                aria-expanded="false"
                aria-controls="collapseExample"
                @click="toggleQuery"
                >展开查询</el-button
              >
            </div>
            <div class="col-sm-4">
              <el-button
                type="primary"
                size="mini"
                icon="el-icon-search"
                @click="getList"
                >立刻查询</el-button
              >
            </div>
          </div>
        </div>

        <div class="container collapse" id="collapseExample">
          <hr />
          <div class="row">
            <div class="col-sm col-md-8 offset-md-1">
              <div class="input-group input-group-sm flex-nowrap">
                <div class="input-group-prepend" style="width: 80px"></div>
                <div class="input-group-prepend">
                  <span class="input-group-text" id="addon-wrapping"
                    >时间：</span
                  >
                  <el-date-picker
                    v-model="searchParams.secondDate"
                    type="datetimerange"
                    value-format="yyyy-MM-dd HH:mm:ss"
                    size="mini"
                    range-separator="至"
                    start-placeholder="开始日期"
                    end-placeholder="结束日期"
                    style="margin-top: 2px; max-width: 350px"
                  >
                  </el-date-picker>
                </div>
              </div>
            </div>
          </div>
          <div class="row">
            <div class="col-sm col-md-9 offset-md-1">
              <div class="input-group input-group-sm flex-nowrap">
                <div class="input-group-prepend" style="width: 80px"></div>
                <div class="input-group-prepend">
                  <span class="input-group-text" id="addon-wrapping"
                    >加油频率：</span
                  >
                </div>
                <input
                  type="text"
                  class="form-control"
                  aria-label="Username"
                  aria-describedby="addon-wrapping"
                  v-model="queryParams.secondStartCountNum"
                />
                <div class="input-group-prepend">
                  <span class="input-group-text" id="addon-wrapping">次</span>
                </div>
                <div class="input-group-prepend">
                  <span class="input-group-text" id="addon-wrapping"
                    >&lt; 加油次数 &lt;=</span
                  >
                </div>
                <input
                  type="text"
                  class="form-control"
                  aria-label="Username"
                  aria-describedby="addon-wrapping"
                  v-model="queryParams.secondEndCountNum"
                />
                <div class="input-group-prepend">
                  <span class="input-group-text" id="addon-wrapping">次</span>
                </div>
              </div>
            </div>
          </div>

          <div class="row">
            <div class="col-sm col-md-9 offset-md-1">
              <div class="input-group input-group-sm flex-nowrap">
                <div class="input-group-prepend" style="width: 80px">
                  <select
                    class="custom-select custom-select-sm"
                    id="inputGroupSelect01"
                    v-model="queryParams.secondAmtFlag"
                  >
                    <option value="1">或者</option>
                    <option value="2">并且</option>
                  </select>
                </div>
                <div class="input-group-prepend">
                  <span class="input-group-text" id="addon-wrapping"
                    >加油金额：</span
                  >
                </div>
                <input
                  type="text"
                  class="form-control"
                  aria-label="Username"
                  aria-describedby="addon-wrapping"
                  v-model.number="queryParams.secondStartAmt"
                />
                <div class="input-group-prepend">
                  <span class="input-group-text" id="addon-wrapping">元</span>
                </div>
                <div class="input-group-prepend">
                  <span class="input-group-text" id="addon-wrapping">
                    &lt; 加油金额 &lt;=
                  </span>
                </div>
                <input
                  type="text"
                  class="form-control"
                  aria-label="Username"
                  aria-describedby="addon-wrapping"
                  v-model.number="queryParams.secondEndAmt"
                />
                <div class="input-group-prepend">
                  <span class="input-group-text" id="addon-wrapping">元</span>
                </div>
              </div>
            </div>
          </div>
          <div class="row">
            <div class="col-sm col-md-9 offset-md-1">
              <div class="input-group input-group-sm flex-nowrap">
                <div class="input-group-prepend" style="width: 80px">
                  <select
                    class="custom-select custom-select-sm"
                    id="inputGroupSelect01"
                    v-model="queryParams.secondLitersFlag"
                  >
                    <option value="1">或者</option>
                    <option value="2">并且</option>
                  </select>
                </div>
                <div class="input-group-prepend">
                  <span class="input-group-text" id="addon-wrapping"
                    >数量(L/kg)</span
                  >
                </div>
                <input
                  type="text"
                  class="form-control"
                  aria-label="Username"
                  aria-describedby="addon-wrapping"
                  v-model.number="queryParams.secondStartLiters"
                />
                <div class="input-group-prepend">
                  <span class="input-group-text" id="addon-wrapping"
                    >(L/kg)</span
                  >
                </div>
                <div class="input-group-prepend">
                  <span class="input-group-text" id="addon-wrapping"
                    >&lt; 数量(L/kg) &lt;=</span
                  >
                </div>
                <input
                  type="text"
                  class="form-control"
                  aria-label="Username"
                  aria-describedby="addon-wrapping"
                  v-model.number="queryParams.secondEndLiters"
                />
                <div class="input-group-prepend">
                  <span class="input-group-text" id="addon-wrapping"
                    >(L/kg)</span
                  >
                </div>
              </div>
            </div>
          </div>
          <div class="row mb-0 mt-3" v-show="queryParams.secondFlag == 1">
            <div class="col-sm-4 offset-sm-3">
              <el-button
                type="info"
                size="mini"
                icon="el-icon-arrow-up"
                data-toggle="collapse"
                data-target="#collapseExample"
                aria-expanded="false"
                aria-controls="collapseExample"
                @click="toggleQuery"
                >展开查询</el-button
              >
            </div>
            <div class="col-sm-4">
              <el-button
                type="primary"
                size="mini"
                icon="el-icon-search"
                @click="getList"
                >立刻查询</el-button
              >
            </div>
          </div>
        </div>
      </div>
      <el-table
        :data="userList"
        @selection-change="selectionChange"
        class="mt-5"
        stripe
      >
        <af-table-column align="left" prop="id" type="selection" />
        <af-table-column label="姓名" align="left" prop="customerName" />
        <af-table-column label="当前归属的标签" align="left" prop="labelName">
          <template slot-scope="scope">
            <span
              class="badge"
              :class="[
                scope.row.labelId === null ? 'badge-danger' : 'badge-success',
              ]"
            >
              {{
                scope.row.labelId === null ? "未标记" : scope.row.labelName
              }}</span
            >
          </template>
        </af-table-column>
        <af-table-column label="手机号" align="left" prop="phone" />
        <af-table-column
          label="最后一笔消费时间"
          align="left"
          prop="createDate"
        />
        <af-table-column
          label="近期详细消费"
          align="left"
          prop="stationName"
          width="160px"
        >
          <template slot-scope="scope">
            <el-button
              type="text"
              icon="el-icon-search"
              class="underline btn24"
              size="mini"
              @click="getConsume(scope.row)"
              >查询</el-button
            >
          </template>
        </af-table-column>
        <af-table-column label="操作" align="left" width="160px" fixed="right">
          <template slot-scope="scope">
            <el-dropdown @command="toLabeled">
              <span class="el-dropdown-link" style="font-size: 12px">
                打标签<i class="el-icon-arrow-down el-icon--right"></i>
              </span>
              <el-dropdown-menu slot="dropdown">
                <el-dropdown-item
                  :command="ele.id + '.' + scope.row.phone"
                  v-for="ele in labelList"
                  :key="ele.id"
                  >{{ ele.labelName }}</el-dropdown-item
                >
              </el-dropdown-menu>
            </el-dropdown>
            <el-popconfirm
              title="此操作会将选中用户强制列为无标签状态，是否继续？"
              confirm-button-text="删除"
              @onConfirm="toUnLableed(scope.row)"
            >
              <el-button
                type="text"
                icon="el-icon-circle-plus-outline"
                class="underline btn24"
                size="mini"
                slot="reference"
                >删标签</el-button
              >
            </el-popconfirm>
          </template>
        </af-table-column>
      </el-table>
      <pagination
        v-show="total > 1"
        :total="total"
        :pageSizes="[10, 50, 100, 200]"
        :page.sync="queryParams.pageNum"
        :limit.sync="queryParams.pageSize"
        @pagination="getList"
      />
      <el-dialog
        title="打标签"
        :visible.sync="toLabeledDialog"
        width="750px"
        @close="toLabeledDialogClose"
        append-to-body
      >
        <div v-if="filterSelectedUser.length != 0">
          <div class="ml-5">
            在您选中的成员中，下面的成员<b>已经被分配到其他标签</b>~
          </div>
          <div class="ml-5">
            如果你想<b>强制拉入此标签</b
            ><span class="badge badge-success ml-1">{{
              translationLabel(currentLabelId)
            }}</span
            >，请<b>先删除下面成员现有的标签</b>，删除完成后点确认即可。
          </div>
          <div class="ml-5">
            如果您<b>直接点击确认按钮</b>，下面的成员将继续留在原标签中，<b
              >不会拉入此标签</b
            ><span class="badge badge-success ml-1">{{
              translationLabel(currentLabelId)
            }}</span
            >。
          </div>

          <div class="app-container">
            <el-table
              :data="filterSelectedUser"
              @selection-change="checkChange"
            >
              <af-table-column align="left" prop="id" type="selection" />
              <af-table-column label="姓名" align="left" prop="customerName" />
              <af-table-column
                label="当前归属的标签"
                align="left"
                prop="labelName"
              >
                <template slot-scope="scope">
                  <span
                    class="badge"
                    :class="[
                      scope.row.labelId === null
                        ? 'badge-danger'
                        : 'badge-success',
                    ]"
                  >
                    {{
                      scope.row.labelId === null
                        ? "未标记"
                        : scope.row.labelName
                    }}</span
                  >
                </template>
              </af-table-column>

              <af-table-column label="手机号" align="left" prop="phone" />

              <af-table-column label="操作" align="left" width="160px">
                <template slot-scope="scope">
                  <el-button
                    type="text"
                    icon="el-icon-circle-plus-outline"
                    class="underline btn24"
                    size="mini"
                    @click="toClearLabel(scope.row)"
                    >删标签</el-button
                  >
                </template>
              </af-table-column>
            </el-table>
            <pagination
              v-show="totalInfo > 0"
              :total="totalInfo"
              :page.sync="query.pageNum"
              :limit.sync="query.pageSize"
              @pagination="getList"
            />
          </div>
        </div>
        <div v-else class="ml-5">
          点击确认按钮，立刻将选中用户拉入标签<span
            class="badge badge-success ml-1"
            >{{ translationLabel(currentLabelId) }}</span
          >~
        </div>
        <div slot="footer" class="dialog-footer">
          <el-button type="primary" @click="handleSubmitLable" size="small"
            >确 定</el-button
          >
          <el-button @click="cancelSubmitLabel" size="small">取 消</el-button>
        </div>
      </el-dialog>

      <el-dialog
        title="近日订单"
        :visible.sync="orderDialog"
        width="750px"
        append-to-body
      >
        <div class="app-container">
          <el-table :data="orderList">
            <!-- <af-table-column label="油站" align="left" prop="stationName" /> -->
            <af-table-column label="订单号" align="left" prop="orderNo" />
            <af-table-column label="油品名称" align="left" prop="oilName" />
            <af-table-column label="油品价格" align="left" prop="oilPirce" />
            <af-table-column
              label="数量(L/kg)"
              align="left"
              prop="orderLiters"
            />
            <af-table-column label="实付金额" align="left" prop="amt" />
            <!-- <af-table-column label="加油枪号" align="left" prop="oilGun" /> -->
            <af-table-column
              label="支付完成时间"
              align="left"
              prop="payDate"
              width="160px"
            >
              <template slot-scope="scope">
                <span>{{
                  parseTime(scope.row.payDate, "{y}-{m}-{d} {h}:{i}:{s}")
                }}</span>
              </template>
            </af-table-column>
          </el-table>
          <pagination
            v-show="orderList.length > 0"
            :total="orderTotal"
            :page.sync="orderQuery.pageNum"
            :limit.sync="orderQuery.pageSize"
            @pagination="getOrderList"
          />
        </div>
      </el-dialog>
    </div>
  </PermissionContainer>
</template>

<script>
import {
  getLabelUser,
  getLabelList,
  delUserLabel,
  addAndDelCustomerLabel,
  getConsume,
  getOilNameList,
} from "@/api/label/labelHistory";
import { getOilListByLogin } from "@/api/dept";

export default {
  name: "Dzk_Bill",
  data() {
    return {
      // 总条数
      total: 0,
      // 客户电子会员卡充值消费记录表格数据
      userList: [],
      searchParams: {
        data: null,
        secondDate: null,
      },
      // 查询参数
      queryParams: {
        pageNum: 1,
        pageSize: 10,

        oilName: null,
        oilId: null,
        labelId: null,

        beginDate: null,
        endDate: null,

        startCountNum: null,
        endCountNum: null,

        amtFlag: "1",
        startAmt: null,
        endAmt: null,

        litersFlag: "1",
        startLiters: null,
        endLiters: null,

        secondFlag: 0,
        secondBeginDate: null,
        secondEndDate: null,

        secondStartCountNum: null,
        secondEndCountNum: null,

        secondAmtFlag: "1",
        secondStartAmt: null,
        secondEndAmt: null,

        secondLitersFlag: "1",
        secondStartLiters: null,
        secondEndLiters: null,
      },
      orderList: [{}],
      orderOpen: false,
      totalInfo: 0,
      query: {
        pageNum: 1,
        pageSize: 10,
        unionId: null,
        customerName: null,
        recordType: null,
        integral: null,
        stationId: null,
        stationName: null,
        levelId: this.levelId,
      },
      dateRangeCreatedDate: [],
      selectedUser: [],
      checkedUser: [],
      toLabeledDialog: false,
      labelList: [],
      oilList: [],
      currentLabelId: undefined,
      orderDialog: false,
      orderTotal: 0,
      orderQuery: {
        pageNum: 1,
        pageSize: 10,
        customerPhone: undefined,
      },
      showQuery: false,
    };
  },
  computed: {
    filterSelectedUser() {
      return this.selectedUser.filter((ele) => {
        return !!ele.labelId && ele.labelId != this.currentLabelId;
      });
    },
  },
  created() {
    this.getList();
    getLabelList()
      .then((res) => {
        if (res.code == 200) {
          this.labelList = res.rows;
        } else {
          throw new Error("");
        }
      })
      .catch(() => {
        this.msgError("拉取标签列表失败，请刷新网页~");
      });
    getOilListByLogin()
      .then((res) => {
        if (res.code == 200) {
          this.oilList = res.rows;
        } else {
          throw new Error("");
        }
      })
      .catch(() => {
        this.msgError("拉取油品列表失败，请刷新网页~");
      });
  },
  methods: {
    getConsume(row) {
      this.orderQuery.customerPhone = row.phone;
      this.getOrderList();
    },
    getOrderList() {
      getConsume(this.orderQuery)
        .then((res) => {
          if (res.code == 200) {
            this.orderList = res.rows;
            this.orderTotal = res.total;
            this.orderDialog = true;
          } else {
            throw new Error("");
          }
        })
        .catch(() => {
          this.msgError("查询近日订单~");
        });
    },
    toLabeledDialogClose() {
      this.selectedUser = [];
      this.checkedUser = [];
    },
    handleSubmitLable() {
      const addArr = [];
      this.selectedUser.map((ele) => {
        if (ele.labelId != this.currentLabelId && !ele.labelId)
          addArr.push(ele.phone);
      });
      addAndDelCustomerLabel({
        labelId: this.currentLabelId,
        flag: "0",
        phoneList: addArr,
      })
        .then((res) => {
          if (res.code == 200) {
            this.getList();
            this.msgSuccess("批量拉入标签成功~");
            this.toLabeledDialog = false;
          } else {
            throw new Error("");
          }
        })
        .catch(() => {
          this.msgError("批量拉入标签失败，请刷新网页后重试~");
          this.toLabeledDialog = false;
        });
    },
    cancelSubmitLabel() {
      this.getList();
      this.toLabeledDialog = false;
    },
    translationLabel(id) {
      const label = this.labelList.find((ele) => {
        return id == ele.id;
      });
      if (label == undefined) {
        return "";
      }
      return label.labelName;
    },
    toUnLableed(row) {
      const delArr = [];
      if (this.selectedUser.length == 0) {
        delArr.push(row.phone);
      } else {
        this.selectedUser.map((ele) => {
          if (!!ele.phone) {
            delArr.push(ele.phone);
          }
        });
      }

      delUserLabel({ phoneList: delArr })
        .then((res) => {
          if (res.code == 200) {
            this.getList();
            this.msgSuccess("删除用户标签成功~");
          } else {
            throw new Error("");
          }
        })
        .catch(() => {
          this.msgError("删除用户标签状态失败，请刷新后重试~");
        });
    },
    toClearLabel(row) {
      const delArr = [];
      if (this.checkedUser.length == 0) {
        this.checkedUser = [row];
        delArr.push(row.phone);
      } else {
        this.checkedUser.map((ele) => {
          delArr.push(ele.phone);
        });
      }

      delUserLabel({ phoneList: delArr })
        .then((res) => {
          if (res.code == 200) {
            this.checkedUser.map((ele) => {
              if (delArr.includes(ele.phone)) {
                ele.labelId = null;
                ele.labelName = null;
              }
            });
            this.msgSuccess("删除用户标签成功~");
          } else {
            throw new Error("");
          }
        })
        .catch(() => {
          this.msgError("删除用户标签状态失败，请刷新后重试~");
        });
    },
    selectionChange(selection) {
      this.checkedUser = [];
      this.selectedUser = selection;
    },
    checkChange(selection) {
      this.checkedUser = selection;
    },
    usageTypeFotmat(row, column) {
      if (row.usageType === "+") {
        return "充值";
      } else if (row.usageType === "-") {
        return "消费";
      }
    },
    cardOilsTypeFotmat(row, column) {
      if (row.cardOilsType === "1") {
        return "汽油";
      } else if (row.cardOilsType === "2") {
        return "柴油";
      } else if (row.cardOilsType === "3") {
        return "非油品";
      } else if (row.cardOilsType === "4") {
        return "LNG";
      } else if (row.cardOilsType === "5") {
        return "CNG";
      }
    },
    /** 查询客户电子会员卡充值消费记录列表 */
    getList() {
      if (this.searchParams.data === null) {
        this.queryParams.beginDate = null;
        this.queryParams.endDate = null;
      } else {
        this.queryParams.beginDate = this.searchParams.data[0];
        this.queryParams.endDate = this.searchParams.data[1];
      }
      if (this.searchParams.secondDate === null) {
        this.queryParams.secondBeginDate = null;
        this.queryParams.secondEndDate = null;
      } else {
        this.queryParams.secondBeginDate = this.searchParams.secondDate[0];
        this.queryParams.secondEndDate = this.searchParams.secondDate[1];
      }
      getLabelUser(this.queryParams).then((response) => {
        this.userList = response.rows;
        this.total = response.total;
      });
    },
    /** 搜索按钮操作 */
    handleQuery() {
      this.queryParams.pageNum = 1;
      this.getList();
    },
    /** 重置按钮操作 */
    resetQuery() {
      this.resetForm("queryForm");
      this.handleQuery();
    },
    orderOpenMethod() {
      this.orderOpen = true;
    },
    toLabeled(idAndPhone) {
      const idAndPhoneArr = idAndPhone.match(/\d{1,}/g);
      const id = idAndPhoneArr[0];
      const phone = idAndPhoneArr[1];

      if (!id || !phone) {
        this.msgError("打标签失败，刷新重试~");
        return;
      }

      if (this.selectedUser.length == 0) {
        const user = this.userList.find((ele) => {
          return ele.phone == phone;
        });
        if (user === undefined) {
          this.msgError("打标签失败，刷新重试~");
          return;
        }
        this.selectedUser = [user];
      }
      this.currentLabelId = id;
      this.toLabeledDialog = true;
    },
    toggleQuery() {
      if (this.queryParams.secondFlag == 0) {
        this.queryParams.secondFlag = 1;
      } else {
        this.queryParams.secondFlag = 0;
      }
    },
  },
};
</script>
<style scoped lang="scss">
.label_batch {
  .container {
    .row {
      margin-bottom: 10px;
    }
  }
}
.el-dropdown-link {
  cursor: pointer;
  color: #409eff;
}
.el-icon-arrow-down {
  font-size: 12px;
}
</style>
